﻿<!--#Include File="../Inc/Const.Asp"-->
<!--#Include File="Inc/Class_Setting.Asp"-->
<%
Select Case Request("Act")

Case "Login"
	Session("Content_IN_Cache") = "" ' 上级退出时保存的内容清空
	Dim Username,Password
	Username = Request.Form("Username")
	Password = Request.Form("Password")
	Username = Replace(Replace(Replace(Username,"'","")," ",""),")","")
	Password = Replace(Password,"'","")
	Password = MD5(Password,32)
	If len(Username) < 3 Then Alert "对不起，你的帐号不正确！","Login.Asp?Username=False"
	Dim Rs,CheckCode
	Set Rs = DB("Select [Username],[Password],[Levels],[ManagePlus],[ManageChannel],[Uploadfileexts],[Uploadfilesize] From [{pre}Admin] Where [Username]='" & Username & "'",1)
	If Rs.Eof Then
		Rs.Close
		Conn.Close
		Alert "对不起，你的帐号不存在！","Login.Asp?Username=False"	
	Else
		If LCase(Password) = LCase(Rs("Password")) Then
			Randomize : Dim RndStr : RndStr = MD5(Rnd & rs("username"),32)
			CheckCode=MD5(Cacheflag & GetIP & RndStr,32)
			call setLogin("admin","username",rs("username"))
			call setLogin("admin","password",rs("password"))
			call setLogin("admin","levels",rs("levels"))
			call setLogin("admin","manageplus",rs("manageplus"))
			call setLogin("admin","managechannel",rs("managechannel"))
			call setLogin("admin","uploadfileexts",rs("uploadfileexts"))
			call setLogin("admin","uploadfilesize",rs("uploadfilesize"))
			Response.Cookies(Cacheflag)("login_admin_username") = rs("username")
			Response.Cookies(Cacheflag)("login_admin_password") = CheckCode
			DB "Update [{pre}Admin] Set CheckCode='" & RndStr & "' Where Username='" & rs("username") & "'",0
			Rs.Close
			Call ClsCache()
			Conn.Close : Set Conn = Nothing
			Response.Write "<Script>top.location.href='Index.Asp';</Script>"
			Response.End
		Else
			Rs.Close
			Conn.Close
			Alert "对不起，你的密码不正确！","Login.Asp?Password=False"	
		End If
	End If
Case "Logout"
	dim loguser : loguser=replace(replace(replace(replace(getlogin("admin", "username"),"'",""),"(",""),"*",""),"?","")
	db "Update [{pre}Admin] Set CheckCode='" & Timer & "' Where Username='" & loguser & "'",0
	call setLogin("admin","username","")
	call setLogin("admin","password","")
	call setLogin("admin","levels","")
	call setLogin("admin","manageplus","")
	call setLogin("admin","managechannel","")
	call setLogin("admin","uploadfileexts","")
	call setLogin("admin","uploadfilesize","")
	Response.Cookies(Cacheflag)("login_admin_username") = ""
	Response.Cookies(Cacheflag)("login_admin_password") = ""
	Response.Write "<Script>top.location.href='Login.Asp';</Script>"
End Select


%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<title>管理登录</title>
<link href="Images/Style.Css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.input {line-height: 100%;font-size: 16px;font-weight: bold;color: #666666;letter-spacing: 1px;margin: 4px;border: 1px solid #D1EAAC;width: 120px;padding-top: 8px;padding-right: 6px;padding-bottom: 3px;padding-left: 6px;}
.inputalt {line-height: 100%;font-size: 16px;font-weight: bold;letter-spacing: 1px;padding-top: 8px;padding-bottom: 3px;background-color: #F0F8E4;border-style: none;margin:4px 4px 4px 10px;}
.inputsubmit {line-height: 100%;font-size: 16px;font-weight: bold;color: #597E21;letter-spacing: 1px;margin:4px 12px 4px 4px;padding:5px 2px 2px 2px;}
.cache {padding: 10px;border: 1px solid #D1EAAC;background-color: #F9FCF1;line-height: 120%;}
-->
</style>
</head>
<body>
<table border="0" align="left" cellpadding="0" cellspacing="0">
	<tr>
		<td bgcolor="#FFFFFF"><table height="38" border="0" cellpadding="5" cellspacing="1" bgcolor="f7f7f7" class="css_table">
				<form id="frm" name="frm" method="post" action="Login.Asp?Act=Login">
					<tr class="css_menu">
						<td class="css_col22"><input name="" type="button" disabled="disabled" class="inputalt" tabindex="8" value="帐号" />
							<input name="Username" value="<%=Request("n")%>" type="text" class="input" id="Username" accesskey="n" tabindex="1" />
							<input name="" type="button" disabled="disabled" class="inputalt" tabindex="9" value="密码" />
							<input name="Password" type="password" value="<%=Request("p")%>" class="input" id="Password"  accesskey="p" tabindex="2" />
						<input name="Submit" type="submit" class="inputsubmit" value="登录"  accesskey="login" tabindex="3" /></td>
					</tr>
				</form>
			</table></td>
	</tr>
</table>
<%
If Len(Session("Content_IN_Cache")) > 0 Then
	Response.Write "<br /><br /><br /><br /><br /><span style='color:red;'>SESSION失败，以下是你在内容管理里最后一次所编辑的内容！ <strong>^_^</strong></span><br /><br /><div class='cache'>"
	Response.Write Session("Content_IN_Cache") & "</div>"
End If
%> 
</body>
</html>
